Skip to content

fix(@angular/build): avoid expanding directory patterns in asset globs - #34494

Merged
alan-agius4 merged 2 commits into
angular:mainfrom
alan-agius4:fix/asset-glob-directory-expansion
Oct 22, 2026
Merged

alan-agius4 merged 2 commits into
angular:mainfrom
alan-agius4:fix/asset-glob-directory-expansion

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Previously, when an asset entry specified a directory pattern in glob (such as glob: 'sub/' or glob: 'sub'), its behavior differed depending on whether ignore was present:

  • Without ignore, the static single-file fast-path checked stats.isFile() and returned no files.
  • With ignore, tinyglobby ran with its default expandDirectories: true option and recursively matched all files in the directory.

This change disables expandDirectories for glob in resolveAssets while preserving directory expansion for ignore patterns via a shared normalizeAssetIgnorePatterns helper.

Previously, when an asset entry specified a directory pattern in `glob` (such as `glob: 'sub/'` or `glob: 'sub'`), its behavior differed depending on whether `ignore` was present: without `ignore`, the static single-file fast-path returned no files, whereas with `ignore`, `tinyglobby` ran with its default `expandDirectories: true` option and recursively matched all files in the directory.

This change disables `expandDirectories` for `glob` in `resolveAssets` while preserving directory expansion for `ignore` patterns via a shared `normalizeAssetIgnorePatterns` helper.
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Oct 22, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 22, 2026 14:50

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors asset resolution and ignore pattern normalization in the Angular build pipeline. It introduces 'normalizeAssetIgnorePatterns' to handle directory-exclusion semantics consistently, ensuring that directory patterns exclude all nested files, and updates the asset matcher and resolver to handle trailing slashes and prevent directory pattern expansion in globs. The review feedback recommends returning a shallow copy of the default ignore patterns array in 'normalizeAssetIgnorePatterns' to prevent potential side-effects from array mutation.

Comment thread packages/angular/build/src/utils/resolve-assets.ts
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 22, 2026
@alan-agius4
alan-agius4 merged commit 65f302c into angular:main Oct 22, 2026
39 of 40 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

@alan-agius4
alan-agius4 deleted the fix/asset-glob-directory-expansion branch October 22, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants